package com.xli.metadata.frameconfig.entity.mapper;

import com.xli.metadata.frameconfig.entity.FrameConfig;
import com.xli.metadata.frameconfig.entity.dto.ConfigAddDTO;
import com.xli.metadata.frameconfig.entity.dto.ConfigUpdateDTO;
import com.xli.metadata.frameconfig.entity.vo.ConfigVO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;


@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface IFrameConfigMapper {

    IFrameConfigMapper INSTANCE = Mappers.getMapper(IFrameConfigMapper.class);

    @Mappings({
            @Mapping(source = "configName", target = "config_name"),
            @Mapping(source = "configValue", target = "config_value"),
            @Mapping(source = "categoryId", target = "category_id"),
            @Mapping(source = "jsBoot", target = "js_boot"),
            @Mapping(source = "orderNum", target = "order_num")
    })
    FrameConfig toEntity(ConfigAddDTO configAddDTO);

    @Mappings({
            @Mapping(source = "configValue", target = "config_value"),
            @Mapping(source = "categoryId", target = "category_id"),
            @Mapping(source = "jsBoot", target = "js_boot"),
            @Mapping(source = "orderNum", target = "order_num")
    })
    FrameConfig toEntity(ConfigUpdateDTO configUpdateDTO);

    @Mappings({
            @Mapping(source = "config_name", target = "configName"),
            @Mapping(source = "config_value", target = "configValue"),
            @Mapping(source = "category_id", target = "categoryId"),
            @Mapping(source = "js_boot", target = "jsBoot"),
            @Mapping(source = "order_num", target = "orderNum")
    })
    ConfigVO toVO(FrameConfig frameConfig);

    @Mapping(target = "id", ignore = true)
    void merge(@MappingTarget FrameConfig target, FrameConfig source);
}
